package com.marry.business.repository.active;

import com.marry.business.domain.MlUser;
import org.springframework.data.r2dbc.repository.Modifying;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Mono;

/**
 * @path：com.marry.business.mapper.active.MlUserMapper.java
 * @className：MlUserMapper.java
 * @description：TODO
 * @author：LiuYun
 * @dateTime：2021/7/8 23:26
 * @editNote：
 */
@Repository
public interface MlUserRepository extends ReactiveCrudRepository<MlUser, Long> {

    /**
     * 新增用户
     * @param user
     * @return
     */
    @Modifying
    @Query("insert into ml_user(account_id, id_card, gender, user_name, open_id, create_date, create_time, update_date, update_time, effective)" +
            "values(:accountId, :idCard, :gender, :userName, :openId, :createDate, :createTime, :updateDate, :updateTome, :effective)")
    Mono<MlUser> insert(MlUser user);

    /**
     * 查询用户
     * @param id
     * @return
     */
    @Query("select * from ml_user where id=:id")
    Mono<MlUser> detail(Long id);
}
